docs: annotate 18 bare const schema = { literals so the snippet gate reads a declared type - #8487
Conversation
…e reads a declared type
`check:doc-snippets` compiles every covered ts/tsx block, but a block whose
literal carries no annotation is judged against nothing: the gate reports it as
JUDGED while consulting no declared type for it. objectui#7972 measured the
cost — objectui#7713's wrong-shaped `filter` sat green on
`objectos-integration.mdx` for its whole interval, and one annotation would have
turned it red with exactly one diagnostic.
Sweep, not a card per page: the population was 30/15 at 05:26Z, 29/14 on
`083e1abbf`, and 28/13 on `76573a184` — it shrinks about as fast as new bare
literals are written, so page-by-page cards buy no net progress.
Re-measured on `76573a184` with triage's own spelling. Of the 28 raw
`git grep -c "const schema = {"` hits, 2 are PROSE (`plugin-form.mdx:394` and
`plugin-grid.mdx:612` are sentences advocating annotation, not code), leaving 26
code occurrences across 11 pages. 18 are annotated here; the other 8 are excluded
with reasons in the PR body.
One block turned red, which is the point of the sweep rather than an obstacle:
`guide/schema-rendering.md` passed a single object to a `page` node's `body`, and
`PageNodeSchema.body` is declared `SchemaNode[]`. Fixed to the declared type
(wrapped in an array), NOT widened — the renderer's `FlatContent` does normalize
a single node, so type and renderer disagree, and that divergence is filed
separately.
The ceiling, stated so nobody over-reads this: `BaseSchema` closes with
`[key: string]: any` (objectui#7927), so these annotations do NOT catch a
misspelled key. They catch a key whose declared TYPE is wrong.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr
…n (206 -> 207)
`README_SAMPLE_FENCE_LINE` keys the objectui#7555 specimen on its fence LINE in
`content/docs/plugins/plugin-markdown.mdx`, deliberately: the pin's own comment
says an edit above it must force a re-declaration here rather than leave a row
that silently covers nothing.
This sweep added one `import type { MarkdownSchema }` line to that page's first
block, which sits above the specimen, so the fence moved 206 -> 207. Re-declared,
and the reason appended to the running record the constant already carries
(objectui#6972's +11 is the previous entry).
The pin still holds what it was written to hold: the block at the new line is the
same specimen, its body still contains `npm install project-name`, and its AST
specifier set is still empty while the retired regex reader still finds
`project-name` in the template literal.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FhBNJcLRZLe8M87VcUgpKr
|
LANDED —
⭐ The control is the one that matters, and it holds: the two prose sentences at The four bare literals remaining on the edited pages are the declared exclusions, verified in the tree rather than taken from the report: ⇒ One is an ellipsis fragment that cannot be annotated; the other carries an explicit
Generated by Claude Code |
Fixes #8125
check:doc-snippetscompiles every coveredts/tsxblock, but a block whose literal carries no annotation is judged against nothing: the gate reports it as JUDGED while consulting no declared type for it. objectui#7972 measured the cost — objectui#7713's wrong-shapedfiltersat green onobjectos-integration.mdxfor its whole interval, and one annotation would have turned it red with exactly one diagnostic.Why one sweep and not fourteen cards
The population reading is the argument. Triage read 30 bare literals across 15 pages at 05:26Z; the card measured 29/14 on
083e1abbf; this branch measures 28/13 on76573a184. objectui#7778's sweep (PR #8040) tookplugin-gantt.mdx's four across, and objectui#7972 (PR #8124) took one more — and the total moved by one. The ratchet shrinks at roughly the rate new bare literals are written, so net progress is about zero and fourteen more single-page cards would buy the same nothing.Re-derived population, and a correction to the census
Re-run on
origin/main76573a184in a dedicated worktree, with triage's own spelling:const schema = {(raw grep hits)const schema: TYPE = {guide/objectos-integration.mdxis at 0 bare / 1 annotated, so PR #8124 did land.The raw count over-counts by 2.
git grep -c "const schema = {"is a whole-file grep and two of its hits are prose, not code — sentences that argue for annotation, outside any fence:content/docs/plugins/plugin-form.mdx:394— "so an un-annotatedconst schema = { … }type-checks whatever is written in it"content/docs/plugins/plugin-grid.mdx:612— "an un-annotatedconst schema = { … }type-checks no matter what is written in it"So the real population is 26 code occurrences across 11 pages. Of those, 18 are annotated here and 8 are excluded below.
After this branch: 41 annotated, and the 10 remaining raw
const schema = {hits are exactly the 2 prose sentences + the 8 exclusions.The ceiling, measured — read this before believing the annotation guards more than it does
BaseSchemacloses with[key: string]: any(objectui#7927), so an annotation does NOT catch a misspelled or undeclared key. It catches a key whose declared TYPE is wrong. That is not a caveat inherited from a card, it is measured on this branch. Three legs, each mutatingcontent/docs/plugins/plugin-editor.mdxon the committed tree and each restored to a byte-identical blob (git checkout HEAD -- path, verified bygit hash-objectagainst the HEAD blob5cb59b077c2407f4f468e331d2e936a88a31b400and by an emptygit diff HEAD):value: zzzUndefinedIdentifier,plugin-editor.mdx:37:10 TS2304: Cannot find name 'zzzUndefinedIdentifier'.zzzUndeclaredKeyNobodyDeclares: 'x',readOnly: 'not-a-boolean',plugin-editor.mdx:37:3 TS2322: Type 'string' is not assignable to type 'boolean or undefined'.A reader who sees an annotation and infers a guarded key set is worse off than one who sees a bare literal. The middle row is why.
One block turned red — that is the finding, not an obstacle
Annotating
content/docs/guide/schema-rendering.mdproduced exactly one diagnostic:The page passed a single object to a
pagenode'sbody.PageNodeSchema.bodyis declaredSchemaNode[](packages/types/src/layout.ts:781, docblock "Main content array"), while the siblingchildrenon the same interface isSchemaNode | SchemaNode[].The renderer disagrees with the type.
FlatContentinpackages/components/src/renderers/layout/page.tsx:266-272readsschema.body || schema.childrenand normalizes a non-array into a one-element array, so a single-nodebodydoes render:That is a contradiction between two shipped surfaces, so it is fixed to the type in the docs and filed — ⛔ the type is not widened here. The docs edit is
body: [{ type: "text", content: "Hello" }]. The divergence is handed to the PM seat below.Exclusions — 8 code occurrences deliberately left bare
Seven are DECLARED FRAGMENTS. A declared fragment is the one thing this gate does not compile, so an annotation on one is a claim the gate structurally cannot re-verify — and the family test triage applied to admit this fold is that each member is independently checkable by the gate's own per-block verdict. A fragment is not. Annotating them to drive a count to zero would put exactly the unverifiable assertion into the docs that this gate's own header calls worse than no marker at all.
guide/plugin-development.md:403src/BoardImpl.test.tsx, aboardschema no published type namesguide/schema-rendering.md:114type: "my-component"— the reader's own registered component, unnamed by any type by constructionguide/schema-rendering.md:406schematwice in one fenceplugin-calendar.mdx:160eventsis the reader's data (marker records the measured TS2552)plugin-calendar.mdx:499{ objectName, calendar }with notypekey; it isObjectCalendar's component propplugin-charts.mdx:290salesDatais the reader's rowsplugin-charts.mdx:302metricsDatais the reader's rowsOne is the ruling carried from objectui#7972 / objectui#7977.
utilities/vscode-extension.mdx:100is theExport to Reactcommand's product reproduced verbatim (PR #8112). Annotating it would make the documented output diverge from what the command actually emits, so it stays bare. Taking it up with the template is objectui#7976's class, not this card's.What this PR deliberately does not do
Per the card's fourth ruling: no gate, no pin, no new scan population. Whether a gate should refuse a bare
const schema = {in acontent/docsblock is a separate ruling this sweep must not pre-empt.One reading for whoever takes that ruling, offered as data and not acted on here: triage's census spelling is keyed to the identifier
schema, so it does not see bare schema literals under any other name. There are 8 of those incontent/docs(blocks/index.mdx:71,guide/schema-rendering.md:367,370,371,372,374,plugin-markdown.mdx:178,208), several of which are prose sketches like{ /* ... */ }that could never be annotated. Extending the sweep to them would be exactly the new scan population ruling 4 forbids.Changes
Two commits.
import typeline plus a type on the declaration, plus the one docs-to-type fix above. Types used:PageNodeSchemaandCardSchemaandObjectMapSchemaandChartSchemafrom@object-ui/types;BarChartSchemaandCodeEditorSchemaandMarkdownSchemafrom the plugin package each page already documents.scripts/__tests__/check-doc-snippet-types.test.ts'sREADME_SAMPLE_FENCE_LINEmoved 206 to 207. The pin keys objectui#7555's specimen on its fence line deliberately, so that an edit above it forces a re-declaration rather than leaving a row that silently covers nothing; this sweep added one import line above it on that page. The constant already carries a running record of such moves (objectui#6972's +11 is the previous entry) and this one is appended to it. The pin still holds what it was written to hold.Verification
All on the final head
a5a67ad47, worktree clean.pnpm check:doc-snippets— the prediction stated before running was that the judged-block count would not move, since no block is added, removed or re-marked; what changes is what 18 of them are judged against. It did not move:Semantic phase: 632 of 632 block(s) judged, 0 failed.— exit 0632 of 632 block(s) judged, 1 failed.— exit 1, theSchemaNode[]diagnostic aboveSemantic phase: 632 of 632 block(s) judged, 0 failed.— exit 0, "Every covered documentation snippet compiles against the built types."The gate's own controls passed on every run (resolution into
packages/types/dist/index.d.ts, sentinel TS2305, positive 0, undeclared TS2307, root-declared TS2307). Its--build-filterclosure was built first — 35/35 turbo tasks successful — so no run is an unbuilt-tree exit 2.Other gates that read these pages, all exit 0:
check:doc-types(1106 blocks, 891typeliterals),check:doc-fences(227 documents),check:doc-examples,check:doc-example-readers,check-doc-links(17 scan roots),check-doc-expression-carriage(report-only),check:control-bytes(6714 files).Tests:
pnpm exec vitest run scripts/__tests__/— 121 files, 3630 tests, all passing. This suite is owed because the diff edits a file underscripts/; it also holds the doc-gate suites directly. The one failure this change produced was the fence-line pin, re-declared as that pin intends, and the suite is green after it.node scripts/check-changeset-presence.mjs— run, not guessed: "9 file(s) changed, 0 of them published source of a package the release covers, 0 of them a manifest whose published contract moved ... no changeset is owed." Noskip-changesetlabel is applied: in this repository the gate's verdict line is authoritative and that label is not this repo's mechanism.node scripts/check-governed-queue-guard.mjs --teston all 9 paths — "NOT GOVERNED — 9 path(s) checked against 5 governed surface(s); none matched." This PR nonetheless opens draft and stays draft, per its dispatch.Repository lint is not owed by this diff and that is a measurement rather than a skip:
eslint.config.jsscopes every rule block tofiles: ['**/*.{ts,tsx}'](and narrower), so.mdand.mdxare outside the linted population entirely. The one.tsfile in the diff is covered by the vitest run above; no configuration in the diff can move the verdict on any untouched file, since no type-aware linting is enabled.Generated by Claude Code